package com.zking.service.impl;

import com.zking.dao.domain.SysRole;
import com.zking.dao.domain.SysRoleResources;
import com.zking.dao.mapper.SysRoleMapper;
import com.zking.dao.mapper.SysRoleResourcesMapper;
import com.zking.service.SysRoleService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

@Service
public class SysRoleServiceImpl implements SysRoleService {

    @Autowired
    private SysRoleMapper sysRoleMapper;

    @Autowired
    private SysRoleResourcesMapper sysRoleResourcesMapper;

    @Override
    public Set<String> findRoleNameByUserId(int userId) {
        return sysRoleMapper.findRoleNameByUserId(userId);
    }

    @Override
    public boolean addAuthority(SysRoleResources roleResources) {
        return sysRoleResourcesMapper.insert(roleResources) > 0;
    }

    @Override
    public boolean deleteAuthority(SysRoleResources roleResources) {
        return sysRoleResourcesMapper.delete(roleResources) > 0;
    }

    @Override
    public List<SysRole> findRolesByUserId(Integer id) {
        return sysRoleMapper.findRolesByUserId(id);
    }
}
